// view/index/addyuanliao/addyuanliao.js
let app = getApp()
let yuming = app.globalData.yuming
let reg = app.globalData.mobile
const request = require('../../config/request');
Page({
    ...request,
    /**
     * 页面的初始数据
     */
    data: {
        buttonClicked: false,
        yuming: yuming,
        heights: "",
        title: '供应商详情',
        spmclist: [],
        spmcindex: 0,
        jinhuonumlist: [], //进货数量
        jinhuonumindex: 0, //进货数量
        numdanindex: 0, //数量单位
        numdanlist: [], //数量单位
        fazlist: [], //  供应商
        fazindex: 0, // 供应商
        xukejylblist: [], //原料类型
        xukejylbindex: 0, //原料类型
        date: '请选择', //开始
        dates: '请选择', //结束
        gongguo: '请选择', //供应商
        yltypeguo: '请选择经营类型', //原料类型
        photo: [],
        wuphoto: '',
        shul: 1,
        lie: [{
            materialName: '',
            materialNums: '',
            materialUnit: ''
        }],
        dianname: '', //店铺名字
        xinyong: '', //信用代码
        fapename: '', //法人姓名
        jylxlist: [], //经营类型
        jylxindex: 0,
        jylxguo: '请选择经营类型',
        xiangadress: '', //详细地址
        jydianhua: '', //经营电话
        yyzz: '', //营业执照
        otherzz: '', //其他证照
        diantz: '', //店头照
        miangz: '', //免冠照
        wudiantz: '', //不带域名店头照
        wuyyzz: '', //不带域名营业执照
        wuotherzz: '', //不带域其他证照
        wumiangz: '', //不带域名免冠照
        jylxid: '', //经营类型id
        sldwguo: '请选择',
        addid: '',
        gongying_xq: '',
        niandu: '', //年度报告
        wuniandu: '',
        yao_xuke: '', //药品许可证
        wuyao_xuke: '',
        zuzhi_daima: '', //组织结构代码证
        wuzuzhi_daima: '',
        yaopin_jinghui: '', //药品经营质量管理规范认证证书
        wuyaopin_jinghui: '',
        xiangguan_yinzhang: '', //相关印章
        wuxiangguan_yinzhang: '',
        suihuo_piao: '', //随货同行单
        wusuihuo_piao: '',
        // kaihu_huming: '', //开户户名
        // kaihu_hang_hao: '', //开户行和账号
        shuiwu_zheng: '', //税务登记证
        wushuiwu_zheng: '',
        jiagong_zhang: '', //加货单位公章
        wujiagong_zhang: '',
        faren_yinzhang: '', //法人代表人印章或签名
        wufaren_yinzhang: '',
        shenfen_fuyin: '', //身份证复印件
        wushenfen_fuyin: '',
        supplier_weituoshu: '', //委托书
        wusupplier_weituoshu: '',

        ying_qitime: '请选择取证时间', //营业执照取证
        ying_shehui_xinydm: '', //营业执照信用代码
        jingying_fanwei: '', //经营范围
        jingying_fangshi: '', //经营方式

        yao_yxq: '请选择有效期', //药品经营许可证 有效期
        yao_shehui_xinydm: '', //药品社会信用代码
        yao_bian: '', //许可证编号
        yao_jingyfw: '', //经营范围
        yao_qitime: '请选择取证时间', //药品取证

        yao_jingy_xuke: '', //药品经营许可证
        wuyao_jingy_xuke: '', //药品经营许可证

        is_xiu: false, //是否修改
    },
    xiug() {
        this.setData({
            is_xiu: true
        })
    },
    bindinput(e) {
        let val = e.detail.value
        let modal = e.currentTarget.dataset.modal
        this.setData({
            [modal]: val
        })
    },
    bindyao_qitime(e) {
        this.setData({
            yao_qitime: e.detail.value
        })
    },
    bindyyzzqu(e) {
        this.setData({
            ying_qitime: e.detail.value
        })
    },
    bindyao_yxq(e) {
        if (this.data.yao_qitime == '请选择取证时间') {
            wx.showToast({
                title: '请选择取证时间',
                icon: 'none'
            })
        } else {
            var y = new Date(e.detail.value).getTime()
            var q = new Date(this.data.yao_qitime).getTime()
            if (y <= q) {
                wx.showToast({
                    title: '有效期不可小于取证时间',
                    icon: 'none'
                })
            } else {
                this.setData({
                    yao_yxq: e.detail.value
                })
            }
        }
    },
    // 开户名
    bindkaihu_huming(e) {
        this.setData({
            kaihu_huming: e.detail.value
        })
    },
    // 开户行
    bindkaihu_hang_hao(e) {
        this.setData({
            kaihu_hang_hao: e.detail.value
        })
    },
    //营业执照一键识别
    yjsbyyz(imgurl) {
        wx.showLoading({
            title: '识别营业执照中',
            icon: 'none'
        })
        let that = this
        this.myRequest(yuming + 'Besall/ai_business_license_v1', {
            imgUrl: imgurl
        }, "POST").then(res => {
            if (res.data.code == 200) {
                wx.showToast({
                    title: '识别成功',
                    icon: 'none'
                })
                wx.hideLoading();
                let data = res.data.data.营业执照识别实体信息
                that.setData({
                    dianname: data.企业名称,
                    xinyong: data.企业统一社会信用编码,
                    xiangadress: data.企业注册地址,
                })
            }
        })
    },
    showModal(e) {
        var aaa = e.currentTarget.dataset.aaa
        var img = e.currentTarget.dataset.img
        this.setData({
            fdaaa: aaa,
            fdimg: img
        })
        let {
            type
        } = e.currentTarget.dataset, va = '';
        if (type == 's2') {
            va = "s2";
        }
        this.setData({
            [va]: true
        })
    },
    confirmbtn(e) {
        console.log(e)
        console.log('点击了从新上传！')
        var aaa = this.data.fdaaa
        var that = this;
        this.myChooseImage(1).then(res => {
            const tempFilePaths = res.tempFilePaths
            this.myUploadImg(tempFilePaths[0], 'file').then(res => {
                var data = JSON.parse(res.data)
                wx.showToast({
                    title: data.msg,
                    icon: 'none'
                })
                var urls = data.httpUrl + data.imgUrl
                //营业执照
                if (aaa == 5) {
                    // that.yjsbyyz(data.imgUrl);
                    that.setData({
                        yyzz: urls,
                        wuyyzz: data.imgUrl
                    })
                }
                // 药品许可证
                if (aaa == 11) {
                    that.setData({
                        yao_xuke: urls,
                        wuyao_xuke: data.imgUrl
                    })
                }
                // 药品经营许可证
                if (aaa == 20) {
                    that.setData({
                        yao_jingy_xuke: urls,
                        wuyao_jingy_xuke: data.imgUrl
                    })
                }


                // 身份证
                if (aaa == 6) {
                    that.setData({
                        otherzz: urls,
                        wuotherzz: data.imgUrl
                    })
                }
                // 店头照
                if (aaa == 7) {
                    that.setData({
                        diantz: urls,
                        wudiantz: data.imgUrl
                    })
                }
                // 免冠照
                if (aaa == 8) {
                    that.setData({
                        miangz: urls,
                        wumiangz: data.imgUrl
                    })
                }
                // 店铺logo
                if (aaa == 9) {
                    that.setData({
                        dianplogo: urls,
                        wudianplogo: data.imgUrl
                    })
                }
                // 年度报告
                if (aaa == 10) {
                    that.setData({
                        niandu: urls,
                        wuniandu: data.imgUrl
                    })
                }

                if (aaa == 12) {
                    that.setData({
                        zuzhi_daima: urls,
                        wuzuzhi_daima: data.imgUrl
                    })
                }
                // 药品经营质量规范认证证书
                if (aaa == 13) {
                    that.setData({
                        yaopin_jinghui: urls,
                        wuyaopin_jinghui: data.imgUrl
                    })
                }
                // 相关印章
                if (aaa == 14) {
                    that.setData({
                        xiangguan_yinzhang: urls,
                        wuxiangguan_yinzhang: data.imgUrl
                    })
                }
                // 随货同行单
                if (aaa == 15) {
                    that.setData({
                        suihuo_piao: urls,
                        wusuihuo_piao: data.imgUrl
                    })
                }
                // 税务登记证
                if (aaa == 16) {
                    that.setData({
                        shuiwu_zheng: urls,
                        wushuiwu_zheng: data.imgUrl
                    })
                }
                // 加货单位公章
                if (aaa == 17) {
                    that.setData({
                        jiagong_zhang: urls,
                        wujiagong_zhang: data.imgUrl
                    })
                }
                // 法人代表人印章或签名
                if (aaa == 18) {
                    that.setData({
                        faren_yinzhang: urls,
                        wufaren_yinzhang: data.imgUrl
                    })
                }
                // 身份复印件
                if (aaa == 19) {
                    that.setData({
                        shenfen_fuyin: urls,
                        wushenfen_fuyin: data.imgUrl
                    })
                }
                // 委托书
                if (aaa == 19) {
                    that.setData({
                        supplier_weituoshu: urls,
                        wusupplier_weituoshu: data.imgUrl
                    })
                }
            })
        })

    },
    cancelBtn() {
        console.log('点击了放大！')
        wx.previewImage({
            urls: [this.data.fdimg]
        })
    },
    getIptValue(e) {
        console.log(e.detail)
    },
    // 供应商验证
    gysyzs() {
        //  else if (this.data.niandu == '') {
        //   wx.showToast({
        //     title: '请上传年度报告',
        //     icon: 'none'
        //   })
        // } 
        if (this.data.yyzz == '') {
            wx.showToast({
                title: '请上传营业执照',
                icon: 'none'
            })
        } else if (this.data.yao_xuke == '') {
            wx.showToast({
                title: '请上传药品生产许可证',
                icon: 'none'
            })
        } else if (this.data.yao_jingy_xuke == '') {
            wx.showToast({
                title: '请上传药品经营许可证',
                icon: 'none'
            })
        } else if (this.data.dianname == '') {
            wx.showToast({
                title: '请输入供应商名称',
                icon: 'none'
            })
        } 
        // else if (this.data.xinyong == '') {
        //     wx.showToast({
        //         title: '请输入供应商编号',
        //         icon: 'none'
        //     })
        // } 
        else if (this.data.fapename == '') {
            wx.showToast({
                title: '请输入法人/负责人',
                icon: 'none'
            })
        } else if (this.data.xiangadress == '') {
            wx.showToast({
                title: '请输入经营地址',
                icon: 'none'
            })
        } else if (this.data.jydianhua == '') {
            wx.showToast({
                title: '请输入联系电话',
                icon: 'none'
            })
        } else if (reg.test(this.data.jydianhua) == false) {
            wx.showToast({
                title: '请输入正确的联系电话',
                icon: 'none'
            })
        } else if (this.data.ying_shehui_xinydm == '') {
            wx.showToast({
                title: '请输入营业执照社会信用代码',
                icon: 'none'
            })
        } else if (this.data.jingying_fanwei == '') {
            wx.showToast({
                title: '请输入营业执照经营范围',
                icon: 'none'
            })
        } else if (this.data.jingying_fangshi == '') {
            wx.showToast({
                title: '请输入营业执照经营方式',
                icon: 'none'
            })
        } else if (this.data.ying_qitime == '请选择取证时间') {
            wx.showToast({
                title: '请选择营业执照取证时间',
                icon: 'none'
            })
        } else if (this.data.yao_shehui_xinydm == '') {
            wx.showToast({
                title: '请输入许可证信用代码',
                icon: 'none'
            })
        } else if (this.data.yao_bian == '') {
            wx.showToast({
                title: '请输入许可证编号',
                icon: 'none'
            })
        } else if (this.data.yao_jingyfw == '') {
            wx.showToast({
                title: '请输入许可证经营范围',
                icon: 'none'
            })
        } else if (this.data.yao_qitime == '请选择取证时间') {
            wx.showToast({
                title: '请选择许可证取证时间',
                icon: 'none'
            })
        } else if (this.data.yao_yxq == '请选择有效期') {
            wx.showToast({
                title: '请选择许可证有效期',
                icon: 'none'
            })
        } else {
            this.tjgys();
        }
        //  else if (this.data.zuzhi_daima == '') {
        //   wx.showToast({
        //     title: '请上传组织结构代码证',
        //     icon: 'none'
        //   })
        // }
        //  else if (this.data.yaopin_jinghui == '') {
        //   wx.showToast({
        //     title: '请上传药品经营质量管理认证证书',
        //     icon: 'none'
        //   })
        // } 
        // else if (this.data.xiangguan_yinzhang == '') {
        //     wx.showToast({
        //         title: '请上传相关印章',
        //         icon: 'none'
        //     })
        // } else if (this.data.suihuo_piao == '') {
        //     wx.showToast({
        //         title: '请上传随货同行单',
        //         icon: 'none'
        //     })
        // } else if (this.data.shuiwu_zheng == '') {
        //     wx.showToast({
        //         title: '请上传税务登记证',
        //         icon: 'none'
        //     })
        // } else if (this.data.jiagong_zhang == '') {
        //     wx.showToast({
        //         title: '请上传加盖供货单位公章',
        //         icon: 'none'
        //     })
        // } else if (this.data.faren_yinzhang == '') {
        //     wx.showToast({
        //         title: '请上传法定代表人印章',
        //         icon: 'none'
        //     })
        // } else if (this.data.shenfen_fuyin == '') {
        //     wx.showToast({
        //         title: '请上传销售人员身份证复印件',
        //         icon: 'none'
        //     })
        // } else if (this.data.supplier_weituoshu == '') {
        //     wx.showToast({
        //         title: '请上传委托书',
        //         icon: 'none'
        //     })
        // } 

        // else if (this.data.xinyong == '') {
        //   wx.showToast({
        //     title: '请输入社会代码',
        //     icon: 'none'
        //   })
        // } else if (this.data.xinyong.length != 18) {
        //   wx.showToast({
        //     title: '请输入18位的社会代码',
        //     icon: 'none'
        //   })
        // } 

        // else if (this.data.kaihu_huming == '') {
        //   wx.showToast({
        //     title: '请输入开户户名',
        //     icon: 'none'
        //   })
        // } else if (this.data.kaihu_hang_hao == '') {
        //   wx.showToast({
        //     title: '请输入开户户号及账号',
        //     icon: 'none'
        //   })
        // }

    },
    // 接口
    tjgys() {
        var that = this
        that.setData({
            buttonClicked: true
        })
        // Shop/shop_jxcsupplier_save
        this.myRequest(yuming + 'Shop/shop_jxcsupplier_save', {
            id: that.data.gongying_xq.id,
            shopId: wx.getStorageSync('shopId'),
            supplier_name: that.data.dianname,
            supplier_number: that.data.xinyong,
            supplier_person: that.data.fapename,
            supplier_address: that.data.xiangadress,
            supplier_tell: that.data.jydianhua,
            supplier_yingye: that.data.wuyyzz,
            social_credit_code: that.data.ying_shehui_xinydm,
            business_scope: that.data.jingying_fanwei,
            operation_mode: that.data.jingying_fangshi,
            supplier_yingye_startime: that.data.ying_qitime,
            supplier_xuke: that.data.wuyao_xuke,
            supplier_jingying_xuke: that.data.wuyao_jingy_xuke,
            supplier_jingying_card: that.data.yao_shehui_xinydm,
            supplier_jingying_number: that.data.yao_bian,
            supplier_jingying_fanwei: that.data.yao_jingyfw,
            supplier_jingying_startime: that.data.yao_qitime,
            supplier_jingying_endtime: that.data.yao_yxq


            //   supplier_khname: that.data.kaihu_huming,
            //   supplier_khhang: that.data.kaihu_hang_hao,
            //   supplier_yingye: that.data.wuyyzz,
            //   supplier_report: that.data.wuniandu,
            //   supplier_xuke: that.data.wuyao_xuke,
            //   supplier_daima: that.data.wuzuzhi_daima,
            //   supplier_renzheng: that.data.wuyaopin_jinghui,
            //   supplier_seal: that.data.wuxiangguan_yinzhang,
            //   supplier_general: that.data.wusuihuo_piao,
            //   supplier_suiwu: that.data.wushuiwu_zheng,
            //   supplier_officialseal: that.data.wujiagong_zhang,
            //   supplier_shouquan: that.data.wufaren_yinzhang,
            //   supplier_fuyin: that.data.wushenfen_fuyin,
            //   supplier_weituoshu: that.data.supplier_weituoshu,
            // thatPhoto: that.data.wuotherzz,
            // doorPhoto: that.data.wudiantz,
            // bareheadedPhoto: that.data.wumiangz
        }, "POST").then(res => {
            wx.showToast({
                title: res.data.msg,
                icon: 'none'
            })
            if (res.data.code == 200) {
                setTimeout(function () {
                    that.setData({
                        is_xiu: false,
                        buttonClicked:false
                    })
                    // wx.navigateBack({
                    //     delta: 0,
                    // })
                }, 1000)
            } else {
                that.setData({
                    buttonClicked: false
                })
            }
        })
    },
    // 差掉
    chadiao(e) {
        var index = e.currentTarget.dataset.index
        var photo = this.data.photo;
        var wuphoto = this.data.wuphoto;
        var dd = wuphoto.split(",")
        photo.splice(index, 1)
        dd.splice(index, 1)
        var rr = dd.join(",")
        this.setData({
            photo: photo,
            wuphoto: rr
        })
    },
    fangdaaa(e) {
        console.log(e)
        var img = e.currentTarget.dataset.img
        wx.previewImage({
            urls: [img]
        })
    },
    // 多组放大
    fangda(e) {
        var img = e.currentTarget.dataset.img
        var list = e.currentTarget.dataset.list
        wx.previewImage({
            current: img,
            urls: list
        })
    },
    // 原料上传
    shangchuan(e) {
        var that = this
        var pics = [];
        var wuphoto = this.data.wuphoto;
        this.myChooseImage(9).then(res => {
            const tempFilePaths = res.tempFilePaths
            for (var i = 0; i < tempFilePaths.length; i++) {
                pics.push(tempFilePaths[i])
            }
            if ((pics.length) + (that.data.photo.length) > 9) {
                wx.showToast({
                    title: '最多可上传' + 9 + "张",
                    icon: 'none'
                })
            } else {
                for (var i = 0; i < tempFilePaths.length; i++) {
                    (function (i) { // 注意这里是形参
                        setTimeout(function () {
                            that.duoupimg(tempFilePaths[i]).then(res => {
                                wx.showLoading({
                                    title: '上传图片中...',
                                });
                                var data = JSON.parse(res.data)
                                var urls = data.httpUrl + data.imgUrl
                                wuphoto = wuphoto.concat(data.imgUrl + ",")
                                that.setData({
                                    photo: that.data.photo.concat(urls),
                                    wuphoto: wuphoto
                                });
                                if (i == tempFilePaths.length - 1) {
                                    wx.hideLoading();
                                }
                            })
                        }, 800 * i); // 还是每秒执行一次，不是累加的
                    })(i) // 注意这里是实参，这里把要用的参数传进去
                }
            }
        })
    },
    // 上传
    chuan(e) {
        var aaa = e.currentTarget.dataset.aaa //店头营业执照
        var that = this;
        this.myChooseImage(1).then(res => {
            const tempFilePaths = res.tempFilePaths
            this.myUploadImg(tempFilePaths[0], 'file').then(res => {
                var data = JSON.parse(res.data)
                wx.showToast({
                    title: data.msg,
                    icon: 'none'
                })
                var urls = data.httpUrl + data.imgUrl
                //营业执照
                if (aaa == 5) {
                    // that.yjsbyyz(data.imgUrl);
                    that.setData({
                        yyzz: urls,
                        wuyyzz: data.imgUrl
                    })
                }
                // 药品许可证
                if (aaa == 11) {
                    that.setData({
                        yao_xuke: urls,
                        wuyao_xuke: data.imgUrl
                    })
                }
                // 药品经营许可证
                if (aaa == 20) {
                    that.setData({
                        yao_jingy_xuke: urls,
                        wuyao_jingy_xuke: data.imgUrl
                    })
                }

                // 身份证
                if (aaa == 6) {
                    that.setData({
                        otherzz: urls,
                        wuotherzz: data.imgUrl
                    })
                }
                // 店头照
                if (aaa == 7) {
                    that.setData({
                        diantz: urls,
                        wudiantz: data.imgUrl
                    })
                }
                // 免冠照
                if (aaa == 8) {
                    that.setData({
                        miangz: urls,
                        wumiangz: data.imgUrl
                    })
                }
                // 店铺logo
                if (aaa == 9) {
                    that.setData({
                        dianplogo: urls,
                        wudianplogo: data.imgUrl
                    })
                }

                // 年度报告
                if (aaa == 10) {
                    that.setData({
                        niandu: urls,
                        wuniandu: data.imgUrl
                    })
                }

                if (aaa == 12) {
                    that.setData({
                        zuzhi_daima: urls,
                        wuzuzhi_daima: data.imgUrl
                    })
                }
                // 药品经营质量规范认证证书
                if (aaa == 13) {
                    that.setData({
                        yaopin_jinghui: urls,
                        wuyaopin_jinghui: data.imgUrl
                    })
                }
                // 相关印章
                if (aaa == 14) {
                    that.setData({
                        xiangguan_yinzhang: urls,
                        wuxiangguan_yinzhang: data.imgUrl
                    })
                }
                // 随货同行单
                if (aaa == 15) {
                    that.setData({
                        suihuo_piao: urls,
                        wusuihuo_piao: data.imgUrl
                    })
                }
                // 税务登记证
                if (aaa == 16) {
                    that.setData({
                        shuiwu_zheng: urls,
                        wushuiwu_zheng: data.imgUrl
                    })
                }
                // 加货单位公章
                if (aaa == 17) {
                    that.setData({
                        jiagong_zhang: urls,
                        wujiagong_zhang: data.imgUrl
                    })
                }
                // 法人代表人印章或签名
                if (aaa == 18) {
                    that.setData({
                        faren_yinzhang: urls,
                        wufaren_yinzhang: data.imgUrl
                    })
                }
                // 身份复印件
                if (aaa == 19) {
                    that.setData({
                        shenfen_fuyin: urls,
                        wushenfen_fuyin: data.imgUrl
                    })
                }

            })
        })
    },
    // 供应商
    dianname(e) {
        this.setData({
            dianname: e.detail.value
        })
    },
    // 经营类型
    bindjylx(e) {
        this.setData({
            jylxguo: this.data.jylxlist[e.detail.value].cartTitle,
            jylxid: this.data.jylxlist[e.detail.value].id
        })
    },
    // 信用代码
    xinyong(e) {
        this.setData({
            xinyong: e.detail.value
        })
    },
    // 法人
    fapename(e) {
        this.setData({
            fapename: e.detail.value
        })
    },
    // 经营地址
    xiangadress(e) {
        this.setData({
            xiangadress: e.detail.value
        })
    },
    // 联系电话
    jydianhua(e) {
        this.setData({
            jydianhua: e.detail.value
        })
    },
    // 添加
    tianjia() {
        var arr = {
            materialName: '',
            materialNums: '',
            materialUnit: ''
        }
        this.setData({
            lie: this.data.lie.concat(arr)
        })
    },
    // 生成二维码
    sheng() {
        wx.navigateTo({
            url: '/my_other/xinxilr/xinxilr',
        })
    },
    // 减
    jian() {
        console.log(1)
        this.setData({
            shul: this.data.shul -= 1
        })
    },
    // 加
    jia() {
        console.log(1)
        this.setData({
            shul: this.data.shul += 1
        })
    },
    // 选择开始时间
    bindDateChange: function (e) {
        console.log('picker发送选择改变，携带值为', e.detail.value)
        this.setData({
            date: e.detail.value
        })
    },
    // 选择结束时间
    bindDateChanges: function (e) {
        console.log('picker发送选择改变，携带值为', e.detail.value)
        this.setData({
            dates: e.detail.value
        })
    },
    // 商品名称
    bindspmc(e) {
        let index = e.detail.value
        this.setData({
            spmcindex: index,
        });
    },
    // 进货数量
    jinhuonum(e) {
        let index = e.detail.value
        this.setData({
            jinhuonumindex: index,
        });
    },
    // 数量单位
    numdan(e) {
        var index = e.currentTarget.dataset.index
        var item = this.data.lie
        item[index].materialUnit = this.data.numdanlist[index].name
        this.setData({
            sldwguo: item[index].materialUnit,
            lie: this.data.lie
        });
    },
    // 获取供应商
    gyslb() {
        var that = this
        this.myRequest(yuming + 'shop/ShopSelectSupplier', {
            shopId: wx.getStorageSync('shopId'),
            page: '-1'
        }, "POST").then(res => {
            that.setData({
                fazlist: res.data.data
            })
        })
    },
    // 供应商
    fazheng(e) {
        let index = e.detail.value
        this.setData({
            gongguo: this.data.fazlist[index].legalPerson,
            gongid: this.data.fazlist[index].id,
        });
    },
    // 原料类型
    xujylb(e) {
        let index = e.detail.value
        this.setData({
            yltypeguo: this.data.xukejylblist[index].name,
        });
    },
    backs() {
        wx.navigateBack({
            delta: 0
        })
    },
    // 经营类型查询
    jylx() {
        var that = this
        var typeMold = ''
        var shopRes = wx.getStorageSync('shopRes')
        if (shopRes == 0) { //0个体 1企业
            typeMold = 2 //1企业 2个体户
        }
        if (shopRes == 1) {
            typeMold = 1
        }
        this.myRequest(yuming + 'Besall/cartrelationList', {
            typeMold: typeMold
        }, "POST").then(res => {
            that.setData({
                jylxlist: res.data.data
            })
        })
    },
    // 获取商品名称
    spmcs(e) {
        var index = e.currentTarget.dataset.index
        var item = this.data.lie
        var value = e.detail.value
        item[index].materialName = value
        this.setData({
            lie: this.data.lie
        })
    },
    // 获取商品数量
    spsls(e) {
        var index = e.currentTarget.dataset.index
        var item = this.data.lie
        var value = e.detail.value
        item[index].materialNums = value
        this.setData({
            lie: this.data.lie
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var gongying_xq = wx.getStorageSync('gongying_xq')
        this.setData({
            heights: wx.getMenuButtonBoundingClientRect().top + 5,
            addid: options.addid,
            gongying_xq,
            dianname: gongying_xq.supplier_name,
            xinyong: gongying_xq.supplier_number,
            xiangadress: gongying_xq.supplier_address,
            //   kaihu_huming: gongying_xq.supplier_khname,
            //   kaihu_hang_hao: gongying_xq.supplier_khhang,
        })
        // 营业执照
        if (gongying_xq.supplier_yingye == null || gongying_xq.supplier_yingye == '') {
            this.setData({
                yyzz: '',
            })
        } else {
            this.setData({
                yyzz: yuming + gongying_xq.supplier_yingye,
                wuyyzz: gongying_xq.supplier_yingye,
            })
        }
        // 药品生产许可证
        if (gongying_xq.supplier_xuke == null || gongying_xq.supplier_xuke == '') {
            this.setData({
                yao_xuke: '',
            })
        } else {
            this.setData({
                yao_xuke: yuming + gongying_xq.supplier_xuke,
                wuyao_xuke: gongying_xq.supplier_xuke,
            })
        }
        // 药品经营许可证
        if (gongying_xq.supplier_jingying_xuke == null || gongying_xq.supplier_jingying_xuke == '') {
            this.setData({
                yao_jingy_xuke: '',
            })
        } else {
            this.setData({
                yao_jingy_xuke: yuming + gongying_xq.supplier_jingying_xuke,
                wuyao_jingy_xuke: gongying_xq.supplier_jingying_xuke,
            })
        }
        // 供应商名称
        if (gongying_xq.supplier_name == '无' || gongying_xq.supplier_name == '' || gongying_xq.supplier_name == null) {
            this.setData({
                dianname: '',
            })
        } else {
            this.setData({
                dianname: gongying_xq.supplier_name,
            })
        }
        // 供应商编号
        if (gongying_xq.supplier_number == '无' || gongying_xq.supplier_number == '' || gongying_xq.supplier_number == null) {
            this.setData({
                xinyong: '',
            })
        } else {
            this.setData({
                xinyong: gongying_xq.supplier_number,
            })
        }
        // 法人负责人
        if (gongying_xq.supplier_person == '无' || gongying_xq.supplier_person == '' || gongying_xq.supplier_person == null) {
            this.setData({
                fapename: '',
            })
        } else {
            this.setData({
                fapename: gongying_xq.supplier_person,
            })
        }
        // 经营地址
        if (gongying_xq.supplier_address == '无' || gongying_xq.supplier_address == null || gongying_xq.supplier_address == '') {
            this.setData({
                xiangadress: '',
            })
        } else {
            this.setData({
                xiangadress: gongying_xq.supplier_address,
            })
        }
        // 联系电话
        if (gongying_xq.supplier_tell == '无' || gongying_xq.supplier_tell == null || gongying_xq.supplier_tell == '') {
            this.setData({
                jydianhua: '',
            })
        } else {
            this.setData({
                jydianhua: gongying_xq.supplier_tell,
            })
        }


        // 营业执照信用代码
        if (gongying_xq.social_credit_code == '无' || gongying_xq.social_credit_code == null || gongying_xq.social_credit_code == '') {
            this.setData({
                ying_shehui_xinydm: '',
            })
        } else {
            this.setData({
                ying_shehui_xinydm: gongying_xq.social_credit_code,
            })
        }
        // 营业执照经营范围
        if (gongying_xq.business_scope == '无' || gongying_xq.business_scope == null || gongying_xq.business_scope == '') {
            this.setData({
                jingying_fanwei: '',
            })
        } else {
            this.setData({
                jingying_fanwei: gongying_xq.supplier_jingying_fanwei,
            })
        }
        // 营业执照经营方式
        if (gongying_xq.operation_mode == '无' || gongying_xq.operation_mode == null || gongying_xq.operation_mode == '') {
            this.setData({
                jingying_fangshi: '',
            })
        } else {
            this.setData({
                jingying_fangshi: gongying_xq.operation_mode,
            })
        }
        // 营业执照取证时间
        if (gongying_xq.supplier_yingye_startime == '无' || gongying_xq.supplier_yingye_startime == null || gongying_xq.supplier_yingye_startime == '') {
            this.setData({
                ying_qitime: '请选择取证时间',
            })
        } else {
            this.setData({
                ying_qitime: gongying_xq.supplier_yingye_startime,
            })
        }



        // 许可证信用代码
        if (gongying_xq.supplier_jingying_card == '无' || gongying_xq.supplier_jingying_card == null || gongying_xq.supplier_jingying_card == '') {
            this.setData({
                yao_shehui_xinydm: '',
            })
        } else {
            this.setData({
                yao_shehui_xinydm: gongying_xq.supplier_jingying_card,
            })
        }
        // 许可证编号
        if (gongying_xq.supplier_jingying_number == '无' || gongying_xq.supplier_jingying_number == null || gongying_xq.supplier_jingying_number == '') {
            this.setData({
                yao_bian: '',
            })
        } else {
            this.setData({
                yao_bian: gongying_xq.supplier_jingying_number,
            })
        }
        // 许可证经营范围
        if (gongying_xq.supplier_jingying_fanwei == '无' || gongying_xq.supplier_jingying_fanwei == null || gongying_xq.supplier_jingying_fanwei == '') {
            this.setData({
                yao_jingyfw: '',
            })
        } else {
            this.setData({
                yao_jingyfw: gongying_xq.supplier_jingying_fanwei,
            })
        }
        // 许可证取证时间
        if (gongying_xq.supplier_jingying_startime == '无' || gongying_xq.supplier_jingying_startime == null || gongying_xq.supplier_jingying_startime == '') {
            this.setData({
                yao_qitime: '请选择取证时间',
            })
        } else {
            this.setData({
                yao_qitime: gongying_xq.supplier_jingying_startime,
            })
        }
        // 许可证有效期
        if (gongying_xq.supplier_jingying_endtime == '无' || gongying_xq.supplier_jingying_endtime == null || gongying_xq.supplier_jingying_endtime == '') {
            this.setData({
                yao_yxq: '请选择有效期',
            })
        } else {
            this.setData({
                yao_yxq: gongying_xq.supplier_jingying_endtime,
            })
        }


        // 年度报告
        // if (gongying_xq.supplier_report == '-') {
        //   this.setData({
        //     niandu: '',
        //   })
        // } else {
        //   this.setData({
        //     niandu: yuming + gongying_xq.supplier_report,
        //     wuniandu: gongying_xq.supplier_report,
        //   })
        // }

        // 组织代码
        // if (gongying_xq.supplier_daima == null) {
        //     this.setData({
        //         zuzhi_daima: '',
        //     })
        // } else {
        //     this.setData({
        //         zuzhi_daima: yuming + gongying_xq.supplier_daima,
        //         wuzuzhi_daima: gongying_xq.supplier_daima,
        //     })
        // }
        // 药品经营质量管理认证证书
        // if (gongying_xq.supplier_renzheng == null) {
        //     this.setData({
        //         yaopin_jinghui: '',
        //     })
        // } else {
        //     this.setData({
        //         yaopin_jinghui: yuming + gongying_xq.supplier_renzheng,
        //         wuyaopin_jinghui: gongying_xq.supplier_renzheng,
        //     })
        // }
        // 相关印章
        // if (gongying_xq.supplier_seal == '-') {
        //     this.setData({
        //         xiangguan_yinzhang: '',
        //     })
        // } else {
        //     this.setData({
        //         xiangguan_yinzhang: yuming + gongying_xq.supplier_seal,
        //         wuxiangguan_yinzhang: gongying_xq.supplier_seal,
        //     })
        // }
        // 随货同行单
        // if (gongying_xq.supplier_general == '-') {
        //     this.setData({
        //         suihuo_piao: '',
        //     })
        // } else {
        //     this.setData({
        //         suihuo_piao: yuming + gongying_xq.supplier_general,
        //         wusuihuo_piao: gongying_xq.supplier_general,
        //     })
        // }
        // 税务登记证
        // if (gongying_xq.supplier_suiwu == null) {
        //     this.setData({
        //         shuiwu_zheng: '',
        //     })
        // } else {
        //     this.setData({
        //         shuiwu_zheng: yuming + gongying_xq.supplier_suiwu,
        //         wushuiwu_zheng: gongying_xq.supplier_suiwu,
        //     })
        // }
        // 加盖供货单位公章
        // if (gongying_xq.supplier_officialseal == '-') {
        //     this.setData({
        //         jiagong_zhang: '',
        //     })
        // } else {
        //     this.setData({
        //         jiagong_zhang: yuming + gongying_xq.supplier_officialseal,
        //         wujiagong_zhang: gongying_xq.supplier_officialseal,
        //     })
        // }
        // 法定代表人印章
        // if (gongying_xq.supplier_shouquan == null) {
        //     this.setData({
        //         faren_yinzhang: '',
        //     })
        // } else {
        //     this.setData({
        //         faren_yinzhang: yuming + gongying_xq.supplier_shouquan,
        //         wufaren_yinzhang: gongying_xq.supplier_shouquan,
        //     })
        // }
        // 销售人员身份证复印件
        // if (gongying_xq.supplier_fuyin == null) {
        //     this.setData({
        //         shenfen_fuyin: '',
        //     })
        // } else {
        //     this.setData({
        //         shenfen_fuyin: yuming + gongying_xq.supplier_fuyin,
        //         wushenfen_fuyin: gongying_xq.supplier_fuyin,
        //     })
        // }
        // 委托书
        // if (gongying_xq.supplier_weituoshu == null) {
        //     this.setData({
        //         supplier_weituoshu: '',
        //     })
        // } else {
        //     this.setData({
        //         supplier_weituoshu: yuming + gongying_xq.supplier_weituoshu,
        //         wusupplier_weituoshu: gongying_xq.supplier_weituoshu,
        //     })
        // }
        // this.jylx()
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },
})